package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划有关接口")
public class NursingPlanController {
    @Autowired
    private NursingPlanService nursingPlanService;

    @GetMapping("search")
    @ApiOperation("分页查询计划项目")
    public ResponseResult<PageResponse<NursingPlanVo>> getByPage(String name, @RequestParam(defaultValue = "1")Integer pageNum,@RequestParam(defaultValue = "10") Integer pageSize,Integer status){
        PageResponse<NursingPlanVo> result=nursingPlanService.getByPage(name,status,pageNum,pageSize);
        return ResponseResult.success(result);
    }
    @PostMapping
    @ApiOperation("护理计划添加")
    public ResponseResult add(@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.add(nursingPlanDto);
        return ResponseResult.success();
    }
    @GetMapping("/{id}")
    @ApiOperation("根据id查询计划")
    public ResponseResult selectById(@PathVariable Integer id){
        NursingPlanVo nursingPlanVo=nursingPlanService.selectById(id);
        return ResponseResult.success(nursingPlanVo);
    }
    @PutMapping("/{id}")
    @ApiOperation("护理计划更新")
    public ResponseResult update(@PathVariable Long id,@RequestBody NursingPlanDto nursingPlanDto){
        nursingPlanService.update(id,nursingPlanDto);
        return ResponseResult.success();
    }
    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult able(@PathVariable Long id,@ApiParam(value = "状态（0：禁用，1：启用）") @PathVariable Integer status){
        nursingPlanService.able(id,status);
        return ResponseResult.success();
    }
    @DeleteMapping("/{id}")
    @ApiOperation("删除")
    public ResponseResult delete(@PathVariable Long id){
        nursingPlanService.delete(id);
        return ResponseResult.success();
    }
    @GetMapping
    @ApiOperation("查询所有护理计划")
    public ResponseResult getAll(){
        List<NursingPlanVo> list=nursingPlanService.getAll();
        return ResponseResult.success(list);
    }
}
